package org.jeecg.modules.article.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;

/**
 * TODO:
 *
 * @author Zhang Hao yu
 * @date 2020/12/16 13:29
 */
@Data
public class ArticleListVO implements Serializable {
    private String id;
    private String articleTitle;
    private String articleAuthor;
    private java.lang.String articleImageString;
    /**创建时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private java.util.Date createTime;

    private byte[] articleImage;

    public byte[] getArticleImage(){
        if(articleImageString==null){
            return null;
        }
        try {
            return articleImageString.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

    public String getArticleImageString(){
        if(articleImage==null || articleImage.length==0){
            return "";
        }
        try {
            return new String(articleImage,"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "";
    }
}